package com.tencent.wxcloudrun.controller.zuke;

import com.tencent.wxcloudrun.config.ApiResponse;
import com.tencent.wxcloudrun.pojo.dto.resp.UdIdToListResp;
import com.tencent.wxcloudrun.pojo.po.XHouseCollect;
import com.tencent.wxcloudrun.service.business.zuke.HouseCollectService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("collect")
public class CollectController {
    @Resource
    private HouseCollectService collectService;

    /**
     * 查看当前房屋是否已收藏
     */
    @GetMapping("/getCollect")
    public ApiResponse<XHouseCollect> getCollect(@RequestParam("houseId") String houseId) {
        return new ApiResponse<>(collectService.getHouseCollect(houseId));
    }

    /**
     * 查看当前租户的所有收藏列表
     */
    @GetMapping("/getAllHouseCollectResp")
    public ApiResponse<List<UdIdToListResp>> getAllHouseCollectResp() {
        return new ApiResponse<>(collectService.getAllHouseCollectResp());
    }

    /**
     * 添加收藏
     */
    @GetMapping("/addCollect")
    public ApiResponse<String> addCollect(@RequestParam("houseId") String houseId) {
        return new ApiResponse<>(collectService.addHouseCollect(houseId));
    }

    /**
     * 取消收藏
     */
    @GetMapping("/delCollect")
    public ApiResponse<String> delCollect(@RequestParam("houseId") String houseId) {
        return new ApiResponse<>(collectService.delHouseCollect(houseId));
    }
}
